package br.com.news.database.services;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import br.com.news.database.daos.interfaces.IContatoDao;
import br.com.news.database.entities.ContatoEntity;
import br.com.news.database.exception.DataBaseException;
import br.com.news.database.utils.GenericService;
import br.com.news.database.utils.interfaces.IGenericDao;
import br.com.news.utils.database.beans.AnuncioBean;
import br.com.news.utils.database.beans.ContatoBean;
import br.com.news.utils.database.exception.DataBaseServiceException;
import br.com.news.utils.database.interfaces.IContatoServiceDb;

@Named
public class ContatoServiceDb extends GenericService<ContatoBean, ContatoEntity, Long> implements IContatoServiceDb{

	@Inject
	private IContatoDao contatoDao;

	@Override
	protected IGenericDao<ContatoEntity, Long> getConcreteDao() {
		return this.contatoDao;
	}
	
	@Override
	public void save(ContatoBean contato) throws DataBaseServiceException {
		try {
			contatoDao.save(parserBean(contato));
		} catch (DataBaseException e) {
			throw new DataBaseServiceException("Erro ao tentar salvar a entidade",e);
		}
	}
	
	@Override
	public List<ContatoBean> buscaContatosNaoEnviados() {
		return parserEntity(contatoDao.buscaContatosNaoEnviados());
	}

}
